package tomasulogui;


public class IntAlu extends FunctionalUnit{
  public static final int EXEC_CYCLES = 1;
  
  int aluIntData;

  public IntAlu(PipelineSimulator sim) {
    super(sim);
  }


  public int calculateResult(int stat) {
      ReservationStation station = stations[stat];
      switch(station.getFunction()){
        case ADD:
            aluIntData = station.data1 + station.data2;
            break;
        case ADDI:
            aluIntData = station.data1 + station.immediate;
            break;
        case AND:
            aluIntData = station.data1 & station.data2;
            break;
        case ANDI:
            aluIntData = station.data1 & station.immediate;
            break;
        case OR:
            aluIntData = station.data1 | station.data2;
            break;
        case ORI:
            aluIntData = station.data1 | station.immediate;
            break;
        case SLL:
            aluIntData = station.data1 << station.immediate;
            break;
        case SRA:
            aluIntData = station.data1 >> station.immediate;
            break;
        case SRL:
            aluIntData = station.data1 >>> station.immediate;
            break;
        case SUB:
            aluIntData = station.data1 - station.data2;
            break;
        case XOR:
            aluIntData = station.data1 ^ station.data2;
            break;
        case XORI:
            aluIntData = station.data1 ^ station.immediate;
            break;
      }
      return aluIntData;
  }

  public int getExecCycles() {
    return EXEC_CYCLES;
  }
}
